package com.suneast.suneaststore.modules.goodsdetail.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.bean.goodsdetail.SpecsDataBean;

import java.util.ArrayList;
import java.util.List;

public class SpecsChooseAdapter extends BaseQuickAdapter<SpecsDataBean.SpecsBean, BaseViewHolder> {

    public SpecsChooseAdapter(int layoutResId, @Nullable List<SpecsDataBean.SpecsBean> data) {
        super(layoutResId, data);
        itemAdapterList = new ArrayList<>();
    }

    private List<SpecsItemAdapter> itemAdapterList;

    @Override
    protected void convert(BaseViewHolder helper, SpecsDataBean.SpecsBean item) {
        Log.e("test", "SpecsChooseAdapter: convert");
        helper.setText(R.id.tv_specification, item.getTitle());
        RecyclerView rv = helper.getView(R.id.rv_specs);
        FlexboxLayoutManager manager = new FlexboxLayoutManager(helper.itemView.getContext());
        rv.setLayoutManager(manager);
        SpecsItemAdapter itemAdapter = new SpecsItemAdapter(R.layout.item_specs_check_box, item.getItems());
        itemAdapter.bindToRecyclerView(rv);
        rv.setAdapter(itemAdapter);
        itemAdapterList.add(itemAdapter);
    }

    public List<SpecsItemAdapter> getItemAdapterList() {
        return itemAdapterList;
    }
}
